var board = new Board();
var player = new Player();


board.initializeClouds(10);
board.initializePlatforms(7);

document.onmousemove = function(e){
	if (player.x + board.canvas.offsetLeft > e.pageX) {
		//if mouse is on the left side of the player.
		player.move('left', 0, board.width);
	} else if (player.x + board.canvas.offsetLeft < e.pageX) {
		//or on right?
		player.move('right', 0, board.width);
	}
};


GameLoop();

function GameLoop(){
	board.clear();
	board.drawClouds();
	board.drawPlatforms();
	board.moveClouds(5);
	board.drawPlayer(player);
	player.jump();
	board.checkCollision(player, 17);
	board.timeout = setTimeout(GameLoop, 1000/50);
}